
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using Apps.Models;
using Apps.Common;
using Microsoft.Practices.Unity;
using System.Transactions;
using Apps.BLL.Core;
using Apps.Locale;
using Apps.IDAL.Sys;
using Apps.Models.Sys;
using Apps.IBLL.Sys;
namespace Apps.BLL.Sys
{
    public partial class SysCalendarPlanBLL
    {


        public  List<SysCalendarPlanModel> GetList(ref GridPager pager, DateTime start, DateTime end,string userId)
        {

            IQueryable<SysCalendarPlan> queryData = null;

            queryData = m_Rep.GetList(a=>a.BeginDate>=start && a.EndDate <=end && a.SysUserId == userId);

            pager.totalRows = queryData.Count();
            //排序
            queryData = LinqHelper.SortingAndPaging(queryData, pager.sort, pager.order, pager.page, pager.rows);
            return CreateModelList(ref queryData);
        }
        public override List<SysCalendarPlanModel> CreateModelList(ref IQueryable<SysCalendarPlan> queryData)
        {

            List<SysCalendarPlanModel> modelList = (from r in queryData
                                                    select new SysCalendarPlanModel
                                                    {
                                                        Id = r.Id,
                                                        Title = r.Title,
                                                        PlanContent = r.PlanContent,
                                                        BeginDate = r.BeginDate,
                                                        EndDate = r.EndDate,
                                                        Color = r.Color,
                                                        TextColor = r.TextColor,
                                                        Url = r.Url,
                                                        SysUserId = r.SysUserId,
                                                        CreateTime = r.CreateTime,

                                                    }).ToList();

            return modelList;
        }

    }
}
